package org.cubikalabs.todolist.common.model
{
	import org.cubikalabs.todolist.vo.Todo;

	public class TodoFormModel
	{
		public static const EDIT_MODE_NEW:String = "new";
		public static const EDIT_MODE_DONE:String = "done";
		public static const EDIT_MODE_UNDONE:String = "undone";
		
		[Bindable]
		public var editMode:String;
		
		private var _todo:Todo;

		[Bindable]
		public function get todo():Todo
		{
			return _todo;
		}
		public function set todo(value:Todo):void
		{
			_todo = value;
			if( !todo || isNaN( todo.id ) )
			{
				editMode = TodoFormModel.EDIT_MODE_NEW;
			} else {
				editMode = ( _todo.done ? TodoFormModel.EDIT_MODE_DONE : TodoFormModel.EDIT_MODE_UNDONE );
			}
			trace( "Mode:" + editMode );

		}
	}
}